import 'package:card_swiper/card_swiper.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'package:pull_to_refresh/pull_to_refresh.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Text Width Example'),
        ),
        body: MyTextWidget(),
      ),
    );
  }
}

class MyTextWidget extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return MyTextWidgetState();
  }

}
class MyTextWidgetState extends State<MyTextWidget> {
  RefreshController refreshController = RefreshController();

  @override
  void initState() {
    print("wqeqwewqe");
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        Container(
          height: 100,
          child: SmartRefresher(
            controller: refreshController,
            scrollDirection: Axis.horizontal,
            enablePullUp: true,
            enablePullDown: true,
            onLoading: (){
              Future.delayed(Duration(seconds: 2), (){
                refreshController.refreshCompleted();
                refreshController.loadComplete();
              });
            },
            onRefresh: (){
              Future.delayed(Duration(seconds: 2), (){
                refreshController.refreshCompleted();
                refreshController.loadComplete();
              });
            },
            child: Swiper(
              loop:false,
              itemCount: 5,
              itemBuilder: (BuildContext context, int index) {
                return Container(
                  color: Colors.blue,
                  width: 100,
                  height: 100,
                  margin: EdgeInsets.all(10),
                  child: Center(
                    child: Text('$index'),
                  ),
                );
              },
            ),
          ),
        ),
      ],
    );
  }
}

